//
//  CityInfoListCell.m
//  CityInfoChooseView
//
//  Created by 正合适 on 2017/10/12.
//  Copyright © 2017年 正合适. All rights reserved.
//

#import "CityInfoListCell.h"

#define RGBAColor(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:a]
#define kSelectedColor RGBAColor(73,144,226,1)
#define kUnselectedColor RGBAColor(51,51,51,1)

@interface CityInfoListCell ()
/**<#desc#>*/
@property (nonatomic, strong) UILabel *nameLabel;
/**<#desc#>*/
@property (nonatomic, strong) UIImageView *imgView;
@end
@implementation CityInfoListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createUI];
    }
    return self;
}

#pragma mark - 初始化界面
- (void)createUI {
    _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(28, 0, 100, [CityInfoListCell cellHeight])];
    _nameLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_nameLabel];
    
    _imgView = [[UIImageView alloc] initWithFrame:CGRectMake(_nameLabel.frame.size.width+_nameLabel.frame.origin.x+5, ([CityInfoListCell cellHeight]-12)/2.0, 12, 12)];
    _imgView.backgroundColor = [UIColor whiteColor];
    [self addSubview:_imgView];
}

- (void)configTitle:(NSString *)title isSelected:(BOOL)isSelected {
    _nameLabel.text = title;
    _nameLabel.textColor = isSelected ? kSelectedColor:kUnselectedColor;
    [_nameLabel sizeToFit];
    _nameLabel.frame = CGRectMake(_nameLabel.frame.origin.x, _nameLabel.frame.origin.y, _nameLabel.frame.size.width, [CityInfoListCell cellHeight]);
    _imgView.frame = CGRectMake(_nameLabel.frame.size.width+_nameLabel.frame.origin.x+5, ([CityInfoListCell cellHeight]-12)/2.0, 12, 12);
    _imgView.image = isSelected ? [UIImage imageNamed:@"ZHUIKit.bundle/choose_gouxuan"]:[UIImage imageNamed:@""];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+ (float)cellHeight {
    return 50;
}

@end
